<template>
  <div class="home-sale-card">
    <div class="sale-card-header">
      <span class="title">今天事件</span>
      <!-- <span>全部<i class="el-icon-arrow-right" /></span> -->
    </div>
    <div class="task-card-content">
      <el-scrollbar class="" style="height:64px">
        <NoData v-if="List.length<=0" height="40" style="height:64px" />
        <div v-for="l in List" :key="l.id" class="task-item">
          <div class="icon">
            <img src="@/assets/images/icon-event-admin.png">
          </div>
          <div class="item-content">
            <div class="item-top-title">
              {{ getDateText(l.startTime) }}</div>
            <div class="item-top-name gray">
              {{ l.theme }}
            </div>
            <div class="item-top-name gray">
              {{ l.startTime|dateFormat('YYYY/MM/DD') }}
            </div>

          </div>
        </div>
      </el-scrollbar>
    </div>

  </div>
</template>
<script>
import { dateTypes } from '@/utils/enums'
import { getEventList } from '@/api/event'
import dayjs from 'dayjs'
export default {
  name: 'SaleCard',
  data() {
    return {
      dateTypes,
      date: 7,
      List: []
    }
  },
  mounted() {
    const date = {
      startCreateTime: dayjs().startOf('date').format('YYYY-MM-DD HH:mm:ss'),
      endCreateTime: dayjs().endOf('date').format('YYYY-MM-DD HH:mm:ss')
    }
    console.log('date:', date)
    getEventList({ searchType: 1, currentPage: 1, pageSize: 3, ...date }).then(res => {
      this.List = res.records || []
    })
  },
  methods: {
    getDateText(d) {
      const day = dayjs(d)
      console.log('day:', day.format('YYYY-MM-DD HH:mm'))
      if (day.hour() >= 11) {
        return `下午 ${day.subtract(12, 'hour').format('HH:mm')}`
      } else if (day.hour() > 11) {
        return `上午 ${day.format('HH:mm')}`
      }
    }

  }
}
</script>
